home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48_1 / pubdom.tar / pubdom / rbj / drawseg < prev    next >
Text File  |  1990-05-30  |  3KB  |  47 lines

  1. %%HP: T(3)A(D)F(.);
  2. @ DRAWSEG Program - Segment of a circle. To be in SEG
  3. @  RBJ 5/30/90  Top Dead Center (TDC) at { 64, 1 }
  4. @              
  5. \<<                                         @ Create, Remove Local Variables
  6.   \<< R\->B SWAP 
  7.       R\->B SWAP 
  8.       2 \->LIST 
  9.   \>>
  10.   0 0 0 0 0 64 \-> f                        @ Function x y -> {#x #y}
  11.                    pf                       @ Pixel Conversion Factor 
  12.                    y                        @ Y Coordinate of Chord
  13.                    c                        @ {x,y} of Center of Circle
  14.                    cl cr                    @ {x,y} Chord Left, Right
  15.                    x                        @ X coordinate of Centerline
  16.   \<<                                       @ MAIN BODY OF DRAWSEG
  17.     ERASE { #0d #0d } PVIEW                 @ Blank out the screen
  18.     Ch 128 /                                @ Real to Pixel Factor based on
  19.     Ri  54 / MAX 'pf' STO                   @ 128 horiz, 54 Vertical
  20.     x                                       @ X coord of Center
  21.     Ra pf / 1 +                             @ Y Coord of Center
  22.     f EVAL   DUP 'c' STO                    @ { X, Y} (and Save copy)
  23.     Ra pf / R\->B                           @ Radius in pixels
  24.     An 2 / DUP                              @ Half Angle
  25.     NEG 90 + SWAP 90 +                      @ Start Stop Angle 90-A/2, 90+A/2
  26.     ARC                                     @ Draw the Arc
  27.     x  1 f EVAL                             @ TDC - One end of Rise { x, y }
  28.     x                                       @ Compute bottom of rise,
  29.     Ri pf / 1 + DUP 'y' STO                 @ Save bottom coodinate
  30.     f EVAL LINE                             @ Pixel List, Draw Line
  31.     Ch 2 / pf / DUP                         @ Half Chord Pixel Count
  32.     NEG x  + SWAP x  +                      @ Left, Right Coordinates
  33.     SWAP y f EVAL DUP 'cl' STO              @ { XL, Y }
  34.     SWAP y f EVAL DUP 'cr' STO              @ { XR, Y }
  35.     LINE                                    @ Draw chord
  36.     cl c LINE                               @ Draw Center to Chord Left
  37.     cr c LINE                               @ Draw Center to Chord Right
  38.     An 4 / DUP                              @ Draw radius at Angle/4
  39.     SIN Ra * pf / x  +                      @ X Component + 64 pixels
  40.     SWAP COS NEG 1 + Ra * pf / 1 +          @ Y Component +  1 pixel
  41.     f EVAL                                  @ Make { X, Y }
  42.     c LINE                                  @ Draw to Center of Circle
  43.     3 FREEZE                                @ Hold Screen
  44.   \>> 
  45. \>>
  46.     
  47.